<?php
/* -=-=-=-=-=-=-=-=-=-=-=-=-
     author by terry
-=-=-=-=-=-=-=-=-=-=-=-=- */
error_reporting(7);
require "global.php";
cpheader();
//set offset
if(!empty($_POST[offset]))
{$offset = $_POST[offset];}
else if  (!empty($_GET[offset]))
{$offset = $_GET[offset]; }
else  {$offset = 0; }


if ($_GET[action]=='view'){

    $cpforms->inithtmlarea();
	if($_GET[action]=="add"){
			$cpforms->formheader(array('title'=>'Add New Applicant (<font color=red>*</font>=Required Field)',
										'name'=>'article',
			                             'enctype'=>'multipart/form-data'));

			$cpforms->makehidden(array('name'=>'action',
									   'value'=>'doinsert'));
			$rs[ad_showtop] = "1";
			$rs[StartDate] = $rs[EndDate] = time();
	}
	if($_GET[action] == "mod"){
			$cpforms->formheader(array('title'=>'Modify Applicant (<font color=red>*</font>=Required Field)',
										'name'=>'article',
				                        'enctype'=>'multipart/form-data'));

			$cpforms->makehidden(array('name'=>'action',
									   'value'=>'update'));
		    $advisoryid = intval($_GET[id]);
			$cpforms->makehidden(array('name'=>'id',
									   'value'=>$advisoryid));
			$cpforms->makehidden(array('name'=>'offset',
									   'value'=>$offset));
            $read =1;
	        $rs  = $DB->fetch_one_array("SELECT * FROM ".$db_prefix."advisory WHERE ad_id =".$advisoryid);
	}

	if($_GET[action]=="view"){
			$cpforms->formheader(array('title'=>'View Applicant (<font color=red>*</font>=Required Field)',
										'name'=>'article'));
		    $advisoryid = intval($_GET[id]);
			$cpforms->makehidden(array('name'=>'id',
									   'value'=>$advisoryid));
			$cpforms->makehidden(array('name'=>'offset',
									   'value'=>$offset));
            $view =1;
	        $rs  = $DB->fetch_one_array("SELECT a.jo_function,a.jo_id,a.jo_title,a.jo_status,a.jo_regtime,a.jo_vdate,a.jo_copname,b.re_id,b.re_fname,b.re_lname, c. * ,d.rc_uname,d.rc_id,b.re_locity,b.re_lostate,b.re_jobtitle,b.re_schoolattend,b.re_desiredpay,b.re_authorize,b.re_schoolattend,b.re_currentpay,b.re_schoolattend,b.re_edulevel,b.re_yearexp,b.re_mgmt,b.re_profit,b.re_detail,b.re_prvemployer,b.re_prvempstatus,b.re_locountry,b.re_professavilable,b.re_sponsorship
					FROM pa_job AS a, pa_resume AS b, pa_applicant AS c, pa_recuiter AS d
					WHERE c.app_jobid = a.jo_id
					AND c.app_resumeid = b.re_id
					 AND c.app_id ='".$advisoryid."'");
	}

	
	?>
     <?       
		   echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Applicant Record</b></td></tr>";
	   	   $cpforms->gethightext(array('text'=>"Submit Date/Time",'name'=>"username",'only'=>1,'value'=>@date("m/d/Y h:i:s A",$rs[app_regtime]),'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Applicant Number",'name'=>"username",'only'=>1,'value'=>$rs[app_id],'read'=>"$read",'view'=>"$view"));

			echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Job Detail</b></td></tr>";	
			$cpforms->gethightext(array('text'=>"ER Job Req #",'name'=>"username",'only'=>1,'value'=>$rs[app_jobid],'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Company Name",'name'=>"copname",'only'=>1,'value'=>$rs[jo_copname],'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Job Posted Date",'name'=>"jobregtime",'only'=>1,'value'=>@date("m/d/Y",$rs[jo_regtime]),'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Job Valid by Date",'name'=>"copname",'only'=>1,'value'=>@date("m/d/Y",strtotime($rs[jo_vdate])),'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Job Title",'name'=>"username",'only'=>1,'value'=>$rs[jo_title],'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Job Function",'name'=>"username",'only'=>1,'value'=>$jobfunction[$rs[jo_function]],'read'=>"$read",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Job Status",'name'=>"username",'only'=>1,'value'=>$jobfillstatus[$rs[jo_status]],'read'=>"$read",'view'=>"$view"));
			
			
			echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Applicant Detail</b></td></tr>";
		   $cpforms->gethightext(array('text'=>"Availability Status",'value'=>$appstatus[$rs[app_status]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Frist Name",'value'=>$rs[re_fname],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Last Name",'value'=>$rs[re_lname],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Location",'value'=>$rs[re_locity].",".$state[$rs[rs_state]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Current Job Title",'value'=>$rs[re_jobtitle],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Current Annual Base Salary",'value'=>"$".number_format($rs[re_currentpay]),'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Desired Annual Base Salary",'value'=>"$".number_format($rs[re_desiredpay]),'read'=>"$read",'view'=>"$view"));
			 
		   echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Applicant Qualifications</b></td></tr>";	
		   $cpforms->gethightext(array('text'=>"Schools Attended",'value'=>$rs[re_schoolattend],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Highest Degree",'value'=>$rs[re_edulevel],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Years of Relevant Work Experience",'value'=>$yearexp2[$rs[re_yearexp]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Years of People Management Experience",'value'=>$yearexp2[$rs[re_mgmt]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Years of Profit & Loss Responsibility ",'value'=>$yearexp2[$rs[re_profit]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Resume Details",'value'=>$rs[re_detail],'read'=>"$read",'view'=>"$view"));
			   
		   echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Work Status, Employment and Professional References</b></td></tr>";		   
		   $cpforms->gethightext(array('text'=>"Authorized to Work Locations",'value'=>$rs[re_authorize],'read'=>"$read",'view'=>"$view"));  
		   $cpforms->gethightext(array('text'=>"Three Previous Employers",'value'=>$rs[re_prvemployer],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Previous Employment Status Checked?",'value'=>$YESNO[$rs[re_prvempstatus]],'read'=>"$read",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Three Professional References Available?",'value'=>$YESNO[$rs[re_professavilable]],'read'=>"$read",'view'=>"$view"));
		   echo "<tr bgcolor=\"#cccccc\"><td align=left colspan=2><b>Recruiter Information</b></td></tr>";
			echo "<tr class=\"firstalt\" nowrap><td width=\"30%\"> Recruiter Information </td><td  ><a href=\"recdetail.php?id=$rs[app_recruitid]\">$rs[rc_uname]</a></td></tr>";		   
			echo "<tr class=\"firstalt\" nowrap><td > Information Release Date/Time </td><td  >".@date("m/d/Y h:i:s A",$rs[app_submittime])."</td></tr>";	
			echo "<tr class=\"firstalt\" nowrap><td > Date of Offer </td><td  >".$rs[app_offerdate]."</td></tr>";
			echo "<tr class=\"firstalt\" nowrap><td > Onboard Date </td><td  >".$rs[app_onboarddate]."</td></tr>";
			echo "<tr class=\"firstalt\" nowrap><td > Offered Salary </td><td  >$".number_format($rs[app_annualsalary])."</td></tr>";
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 ?>

<?
		
      if($_GET[action]=="view"){$cpforms->noformfooter();}
	   else{ $cpforms->formfooter(array('confirm'=>1));}
}


if ($_GET[action]=="list"){


	if($_GET[action]=="list"){   
		$nav = new buildNav;

		$total = $DB->fetch_one_array("SELECT COUNT(*) as count FROM(SELECT c.* FROM pa_job AS a, pa_resume AS b, pa_applicant AS c, pa_recuiter AS d WHERE c.app_jobid = a.jo_id AND c.app_resumeid = b.re_id AND (c.app_recruitid = d.rc_id OR c.app_recruitid = 0) GROUP BY c.app_id ) AS BB");

		$nav->total_result = $total[count];
 
		$by = "  c.app_id"; 
		$order = "DESC";

        $_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;$_GET[order3]==''&&$order3=1;$_GET[order4]==''&&$order4=1;
		$_GET[order5]==''&&$order5=1;$_GET[order6]==''&&$order6=1;$_GET[order7]==''&&$order7=1;$_GET[order8]==''&&$order8=1;$_GET[order9]==''&&$order9=1;$_GET[order10]==''&&$order10=1;
		switch($_GET[swh]){
		   case 1:
			   $by = "c.app_id";
               if($_GET[order1]==1){$order1=2; $order=" DESC ";
			   $image1 = "<img src=\"images/dot1.gif\">";}else{$order1=1;$order=" ASC ";
			   $image1 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 2:
               $by = "b.re_fname";
               if($_GET[order2]==1){$order2=2; $order=" DESC ";$image2 = "<img src=\"images/dot1.gif\">";}else{$order2=1;$order=" ASC ";$image2 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 3:
                $by = "a.jo_id";
               if($_GET[order3]==1){$order3=2; $order=" DESC ";$image3 = "<img src=\"images/dot1.gif\">";}else{$order3=1;$order=" ASC ";$image3 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 4:
               $by = "a.jo_title";
               if($_GET[order4]==1){$order4=2; $order=" DESC ";$image4 = "<img src=\"images/dot1.gif\">";}else{$order4=1;$order=" ASC ";$image4 = "<img src=\"images/dot2.gif\">";}
			   break;	
		    case 5:
                $by = "a.jo_status";
               if($_GET[order5]==1){$order5=2; $order=" DESC ";$image5 = "<img src=\"images/dot1.gif\">";}else{$order5=1;$order=" ASC ";$image5 = "<img src=\"images/dot2.gif\">";}
			   break;	
    	    case 6:
               $by = "a.jo_copname";
               if($_GET[order6]==1){$order6=2; $order=" DESC ";$image6 = "<img src=\"images/dot1.gif\">";}else{$order6=1;$order=" ASC ";$image6 = "<img src=\"images/dot2.gif\">";}
			   break;	
		   case 7:
               $by = "c.app_regtime";
               if($_GET[order7]==1){$order7=2; $order=" DESC ";$image7 = "<img src=\"images/dot1.gif\">";}else{$order7=1;$order=" ASC ";$image7 = "<img src=\"images/dot2.gif\">";}
			   break;	
		    case 8:
               $by = "d.rc_uname";
               if($_GET[order8]==1){$order8=2; $order=" DESC ";$image8 = "<img src=\"images/dot1.gif\">";}else{$order8=1;$order=" ASC ";$image8 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 9:
               $by = "c.app_fee";
               if($_GET[order9]==1){$order9=2; $order=" DESC ";$image9 = "<img src=\"images/dot1.gif\">";}else{$order9=1;$order=" ASC ";$image9 = "<img src=\"images/dot2.gif\">";}
			   break;
		    case 10:
               $by = "c.app_hired";
               if($_GET[order10]==1){$order10=2; $order=" DESC ";$image10 = "<img src=\"images/dot1.gif\">";}else{$order10=1;$order=" ASC ";$image10 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 11:
               $by = "c.app_offerdate";
               if($_GET[order11]==1){$order11=2; $order=" DESC ";$image11 = "<img src=\"images/dot1.gif\">";}else{$order11=1;$order=" ASC ";$image11 = "<img src=\"images/dot2.gif\">";}
			   break;
            case 12:
               $by = "c.app_onboarddate";
               if($_GET[order12]==1){$order12=2; $order=" DESC ";$image12 = "<img src=\"images/dot1.gif\">";}else{$order12=1;$order=" ASC ";$image12 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 13:
               $by = "a.app_annualsalary";
               if($_GET[order13]==1){$order13=2; $order=" DESC ";$image13 = "<img src=\"images/dot1.gif\">";}else{$order13=1;$order=" ASC ";$image13 = "<img src=\"images/dot2.gif\">";}
			   break;
		}

		
		$nav->execute("SELECT  a.jo_id,a.jo_title,a.jo_status,a.jo_copname,b.re_id,b.re_fname,b.re_lname, c. * ,d.rc_uname,d.rc_id 
					FROM pa_job AS a, pa_resume AS b, pa_applicant AS c, pa_recuiter AS d
					WHERE c.app_jobid = a.jo_id
					AND c.app_resumeid = b.re_id
					AND (c.app_recruitid = d.rc_id OR c.app_recruitid = 0) GROUP BY c.app_id ORDER BY $by $order");

    }
	
	echo $nav->title("Applicant list");
    echo $nav->pagenav();

    echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"1\" class=\"tableoutline\">
	<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
	   <tr align=\"center\" class=\"tbhead\">
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order1=$order1&swh=1\">$image1 Applicant #</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order2=$order2&swh=2\">$image2 Applicant Name</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order3=$order3&swh=3\">$image3 Job Req#</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order4=$order4&swh=4\">$image4 Job Title </a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order5=$order5&swh=5\">$image5 Job Status</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order6=$order6&swh=6\">$image6 Company Name</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order7=$order7&swh=7\">$image7 Submit Date</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order8=$order8&swh=8\">$image8 Recuriter Username </a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order9=$order9&swh=9\">$image9 Fee </a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order10=$order10&swh=10\">$image10 Hired?</a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order11=$order11&swh=11\">$image11 Offer Date </a></td>
	    <td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order12=$order12&swh=12\">$image12 Onboard Date</a></td>
		<td nowrap  width=\"10%\"><a href=\"applicant.php?action=list&offset=$_GET[offset]&order13=$order13&swh=13\">$image13 Salary</a></td>
		<td nowrap  width=\"10%\">Check Date</td>
		<td nowrap  width=\"10%\"> Action </td>
	   </tr>\n";
    while ($list = $DB->fetch_array($nav->sql_result)){
           echo "<tr class=".getrowbg().">
                      <td align=\"left\" >".$list[app_id]."</td>
					  <td align=\"left\" >".$list[re_fname]." ".$list[re_lname]."</td>
					  <td align=\"left\" >".$list[jo_id]."</td>
                      <td align=\"left\" >".$list[jo_title]."</td>
                      <td align=\"left\" >".$jobfillstatus[$list[jo_status]]."</td>
					  <td align=\"left\" >".$list[jo_copname]."</td>
					  <td align=\"left\" >".date('m/d/Y',$list[app_regtime])."</td>
					  <td align=\"left\" >".$list[rc_uname]."</td>
					  <td align=\"left\" >".$list[app_fee]."%</td>
					  <td align=\"left\" >".$YESNO[$list[app_hired]]."</td>
					  <td align=\"left\" >".$list[app_offerdate]."</td>
					  <td align=\"left\" >".$list[app_onboarddate]."</td>
					  <td align=\"left\" >$".number_format($list[app_annualsalary])."</td>
					  <td align=\"left\" >".@date('m/d/Y h:i:s',$list[app_submittime])."</td>
                      <td align=\"left\" nowrap><a href=\"applicant.php?action=view&offset=$_GET[offset]&id=$list[app_id]\">View</a> | <a href=\"applicant.php?action=kill&offset=$_GET[offset]&id=$list[app_id]\">Delete</a>";
    }
	if(empty($total[count])){
			echo "<tr><td><font color=red>No results!</font></td></tr>";
   }
    echo "</table>\n";
    echo $nav->pagenav();
}

if ($_GET[action]=="kill"){
    $cpforms->formheader(array('title'=>'Sure to delete this?'));
    $cpforms->makehidden(array('name'=>'action',
                                'value'=>'remove'));
    $cpforms->makehidden(array('name'=>'advisoryid',
                                'value'=>$_GET[id]));
	$cpforms->makehidden(array('name'=>'offset',
                                'value'=>$_GET[offset]));
    $cpforms->formfooter(array('confirm'=>2));
}


if( $_POST[action]=="remove"){
    $DB->query("DELETE FROM ".$db_prefix."advisory WHERE ad_id='$_POST[advisoryid]'");
    redirect("./applicant.php?action=list&offset=".$offset,"<font color=red>Deleted Successfully!</font>");
}



if ($_POST[action]=="doinsert"){

	$username       = htmlspecialchars(trim($_POST[username]));
	$password       = md5(trim($_POST[password]));
	$firstname      = htmlspecialchars(trim($_POST[firstname]));
	$lastname       = htmlspecialchars(trim($_POST[lastname]));
	$email          = htmlspecialchars(trim($_POST[email]));
	$companyname    = htmlspecialchars(trim($_POST[companyname]));
	$phone          = htmlspecialchars(trim($_POST[phone]));
	$fax            = htmlspecialchars(trim($_POST[fax]));
	$industry       = htmlspecialchars(trim($_POST[industry]));
	$address        = htmlspecialchars(trim($_POST[address]));
	$locity         = htmlspecialchars(trim($_POST[locity]));
	$lostate        = htmlspecialchars(trim($_POST[lostate]));
	$locountry      = htmlspecialchars(trim($_POST[locountry]));
	$generalarea    = htmlspecialchars(trim($_POST[generalarea]));
	$indicate       = htmlspecialchars(trim($_POST[indicate]));
	$spokenlanguage = htmlspecialchars(trim($_POST[spokenlanguage]));
	$subjectdes     = ucfirst(htmlspecialchars(trim($_POST[subjectdes])));
	$shortdes       = ucfirst(htmlspecialchars(trim($_POST[shortdes])));
	$longdes        = ucfirst(htmlspecialchars(trim($_POST[longdes])));
    $status         = trim($_POST[status]);
	$description    = ucfirst(htmlspecialchars(trim($_POST[description])));
   
	 if($_FILES["uploadfile"][name]!=''){
		   $f = new upfile("../uploadfiles/advisory/","gif,jpg,png");
		   if($f->upload("uploadfile")){
			 $filename1 = $f->savename;
			 $filename1p = $filename1;
			 //切割
			 if(file_exists("../uploadfiles/advisory/".$filename1)){
				$big_image_name = "../uploadfiles/advisory/".$filename1;
				$filename1 = substr($filename1, 0, -4);
				$cutbig = "../uploadfiles/advisory/".$filename1;
				@miniature($big_image_name, $cutbig, $max_width = 100, $max_height = 100, $resize = 1);
			 } 
		   }
		}
    
	$checkadvisory = $DB->fetch_one_array("SELECT * FROM ".$db_prefix."advisory WHERE ad_uname ='".$username."'");
    if ($checkadvisory) {
        pa_exit("<font color=red>The username is exist!</font>");
    }

    $date = date("Y-m-d",time());
	$sql = "INSERT INTO ".$db_prefix."advisory (  `ad_uname` , `ad_pword` , `ad_fname` , `ad_lname` , `ad_copname`, `ad_email` , `ad_phone` , `ad_fax` , `ad_industry` ,`ad_address`, `ad_city` , `ad_state` , `ad_country` , `ad_generalarea` , `ad_indicate` , `ad_spoken` , `ad_subjectdes` , `ad_shortdes` , `ad_longdes` , `ad_upload`  , `ad_regtime`,`ad_status` ) 
   VALUES (
	'".$username."', '".$password."', '".$firstname."', '".$lastname."', '".$companyname."', '".$email."','".$phone."', '".$fax."', '".$industry."','".$address."', '".$locity."', '".$lostate."', '".$locountry."', '".$generalarea."', '".$indicate."', '".$spokenlanguage."', '".$subjectdes."', '".$shortdes."', '".$longdes."', '".$filename1p."', '".time()."','".$status."'
	);";
    $DB->query($sql);

    redirect("./applicant.php?action=list","<font color=red>Added Successfully!</font>");
}


if ($_POST[action]=="update"){

	$topic          = htmlspecialchars(trim($_POST[topic]));
	$password       = md5(trim($_POST[password]));
	$firstname      = htmlspecialchars(trim($_POST[firstname]));
	$lastname       = htmlspecialchars(trim($_POST[lastname]));
	$email          = htmlspecialchars(trim($_POST[email]));
	$companyname    = htmlspecialchars(trim($_POST[companyname]));
	$phone          = htmlspecialchars(trim($_POST[phone]));
	$fax            = htmlspecialchars(trim($_POST[fax]));
	$companyurl     = htmlspecialchars(trim($_POST[companyurl]));
	$industry       = htmlspecialchars(trim($_POST[industry]));
	$address        = htmlspecialchars(trim($_POST[address]));	
	$locity         = htmlspecialchars(trim($_POST[locity]));
	$lostate        = htmlspecialchars(trim($_POST[lostate]));
	$locountry      = htmlspecialchars(trim($_POST[locountry]));
	$generalarea    = htmlspecialchars(trim($_POST[generalarea]));
	$indicate       = htmlspecialchars(trim($_POST[indicate]));
	$spokenlanguage = htmlspecialchars(trim($_POST[spokenlanguage]));
	$subjectdes     = htmlspecialchars(trim($_POST[subjectdes]));
	$shortdes       = htmlspecialchars(trim($_POST[shortdes]));
	$longdes        = htmlspecialchars(trim($_POST[longdes]));
	$status         = trim($_POST[status]);

	if ($email=="") {
        pa_exit("<font color=red>Please enter the email!</font>");
    }

	if($_FILES["uploadfile"][name]!=''){
		   $f = new upfile("../uploadfiles/advisory/","gif,jpg,png");
		   if($f->upload("uploadfile")){
			 $filename1 = $f->savename;
			 $upload = ",`ad_upload` = '$filename1'  ";
			 //切割
			 if(file_exists("../uploadfiles/advisory/".$filename1)){
				$big_image_name = "../uploadfiles/advisory/".$filename1;
				$filename1 = substr($filename1, 0, -4);
				$cutbig = "../uploadfiles/advisory/".$filename1;
				@miniature($big_image_name, $cutbig, $max_width = 100, $max_height = 100, $resize = 1);
			 } 
		   }
	}

	if($_POST[password]){
	  $pwd =  "`ad_pword`='$password' ,";
	}

    $sql = "UPDATE ".$db_prefix."advisory 
	                 SET 
					 ".$pwd."
					`ad_fname`='".$firstname."'  ,
				    `ad_lname`='".$lastname."'  ,
					`ad_email`='".$email."' , 
					`ad_copname`='".$companyname."' ,
					`ad_phone`='".$phone."' ,
					`ad_fax`='".$fax."'  ,
					`ad_industry`='".$industry."' ,
					`ad_address`='".$address."',
					`ad_city`= '".$locity."', 
					`ad_state`='".$lostate."' ,
					`ad_country`='".$locountry."' ,
					`ad_generalarea`='".$generalarea."' ,
					`ad_indicate`='".$indicate."' ,
					`ad_spoken`='".$spokenlanguage."' , 
					`ad_subjectdes`='".$subjectdes."',
					`ad_shortdes`='".$shortdes."',
					`ad_longdes`='".$longdes."',
					`ad_status` ='".$status."'
					".$upload."
					WHERE ad_id= '".$_POST[id]."'";

	$DB->query($sql);

    redirect("./applicant.php?action=list&offset=".$offset,"<font color=red>Modified Successfully!</font>");
}
cpfooter();
?>